package com.chuangmi.mp4;

import java.nio.ByteBuffer;

/**
 * Created by shd on 2017/9/19.
 */

public class ImiVideoSynthesis {

    public static final int VIDEO_CODEC_ID_H264 = 0;
    public static final int VIDEO_CODEC_ID_H265 = 1;

    public static final int AUDIO_CODEC_ID_AAC = 0;
    public static final int AUDIO_CODEC_ID_G711 = 1;

    public static final int CONTAINER_FORNAT_MP4 = 0;

    public native int initMp4();


    public native int createFile(final String path,
                                 int container,
                                 int videoCodecID,
                                 int audioCodecID,
                                 int vFps,
                                 int vWidth,
                                 int vHeight,
                                 int aChannel,
                                 int aSampleRate,
                                 int[] handle);


    public native int writeVideoFrameFile(int[] handle,
                                          ByteBuffer data,
                                          int dataLen,
                                          int vTimesTamp,
                                          boolean isKeyFrame);

    public native int writeAudioFrameFile(int[] handle,
                                          ByteBuffer data,
                                          int dataLen,
                                          int aTimesTamp);

    public native int closeFile(int[] handle);


    public native int openFile(final String path,
                               int[] container,
                               int[] videoCodecID,
                               int[] audioCodecID,
                               int[] vFps,
                               int[] vWidth,
                               int[] vHeight,
                               int[] aChannel,
                               int[] aSampleRate,
                               int[] aBitrate,
                               int[] handle);

    //get frame
    public native int getVideoFrame(int[] handle,
                                    byte[] data,
                                    int[] dataLen,
                                    int[] vTimesTamp,
                                    int[] isKeyFrame,
                                    int[] isAudioFrame);


    public native int closeFileForOpen(int[] handle);


}
